package cn.jbit.ams.detection;


import java.util.List;
import java.util.TimerTask;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.bdqn.chit;

import cn.jbit.ams.order.biz.OrderService;
import cn.jbit.ams.user.biz.UserService;
import cn.jbit.ams.user.pojo.Order;
import cn.jbit.ams.user.pojo.User;


@Component
public class TimeTask extends TimerTask{

	@Autowired
	private OrderService orderService;

	@Autowired
	private UserService userService;

	// 静态初使化当前类
	public static TimeTask timeTask;

	@PostConstruct
	public void init() {
		timeTask = this;
	}
	@Override
	public void run() {
		List<Order> orderList=timeTask.orderService.getOrderTime();
		if(orderList.size()>0) {

			List<User> userAdmin=timeTask.userService.getAdminUser();
			try {
				for (User user : userAdmin) {
					chit.sendSms("223456");
					//填写你需要测试的手机号码
				}
			} catch (ClientException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}